package com.school.admin.controller;


import com.school.admin.common.annotation.DataAuthority;
import com.school.admin.common.result.R;
import com.school.admin.entity.MallMenu;
import com.school.admin.service.MallMenuRoleService;
import com.school.admin.service.MallMenuService;
import com.school.admin.service.MallSysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 菜单 前端控制器
 * </p>
 *
 * @author sunpx
 * @since 2022-03-24
 */
@RestController
@RequestMapping("/mall-menu")
@Api(tags = "菜单相关")
public class MallMenuController {

    @Autowired
    private MallMenuRoleService mallMenuRoleService;

    @Autowired
    private MallSysRoleService mallSysRoleService;

    @Autowired
    private MallMenuService mallMenuService;

    @DeleteMapping("del/{id}")
    @ApiOperation("删除菜单")
    @DataAuthority(name = "删除菜单",key = 3)
    public R getUpt(@PathVariable String id) {
        return R.th(mallMenuService.delModel(id));
    }


    /**
     * @return : top.zzzit.main.matter.common.result.R
     * @author : zzz
     * @desc : TODO 保存菜单信息
     * @date :  00:58:46
     * @params : zzzitMenu
     */
    @PostMapping("save")
    @ApiOperation("保存菜单")
    @DataAuthority(name = "保存菜单",key = 1)
    public R getAll(@RequestBody MallMenu menu) {
        return R.th(mallMenuService.saveModel(menu));
    }


    @PostMapping("upt")
    @ApiOperation("更新菜单")
    @DataAuthority(name = "更新菜单",key = 2)
    public R getUpt(@RequestBody MallMenu menu) {
        return R.th(mallMenuService.updateById(menu));
    }


}

